<?php
//$image_path = base_path() . path_to_theme();
$login_button_value="";
?>
<input id="field_email" name="name" type="text" value="username" onfocus="defValue(this,'username');" onblur="defValue(this,'username');"/>&nbsp;
<input id="field_password" name="pass" type="text" value="password" onfocus="defValue(this,'password','password');" onblur="defValue(this,'password','password');"/>
<?php if( arg(0)=='user' )
            $login_button_value = 'login';
?>
<input type="submit" class="form-submit" value="登录"/>
<input type="hidden" name="form_build_id" id="<?php form_clean_id('edit-' . drupal_get_token() . '-form-token'); ?>" value="<?php drupal_get_token(); ?>"  />
<input type="hidden" name="form_id" id="edit-user-login-block" value="user_login_block" />
<?php if(arg(0) != 'user') : ?>
<a class="textLink" href="<?php print url('user/register'); ?>">注册</a>
<a class="textLink" href="<?php print url('user/password'); ?>">忘记密码</a>
<?php endif; ?>
<script>
function defValue(myField, originalString, myType)
{
    if (myField.justReplaced) { //If we are focusing on a just-created clone, avoid the "onFocus" to reset the field value
        myField.justReplaced = false;
    } else {
        myType = (myType) ? myType : 'text';
        if (myField.value == '') { //If value is empty, put original string
            newField = changeInputType(myField, 'text', false);
            newField.value = originalString;
        }
        else if (myField.value == originalString) { //If value is original string, put it empty
            newField = changeInputType(myField, myType, true);
            newField.value = '';
        }
    }
}
function changeInputType(oldObject, oType, oFocus) {
    //The only way to successfully modify a field type in both IE and MOZ is to replace it with a clone.
    var newObject = document.createElement('input');
    newObject.type = oType;
    oldObject.focusDO = oldObject.onfocus; oldObject.onfocus='';
    oldObject.blurDO = oldObject.onblur; oldObject.onblur='';
    if(oldObject.size) newObject.size = oldObject.size;
    if(oldObject.value) newObject.value = oldObject.value;
    if(oldObject.name) newObject.name = oldObject.name;
    if(oldObject.id) newObject.id = oldObject.id;
    if(oldObject.className) newObject.className = oldObject.className;
    newObject.onfocus = oldObject.focusDO;
    newObject.onblur = oldObject.blurDO;
    oldObject.parentNode.replaceChild(newObject,oldObject);
    if(oFocus) { //If user FOCUSED on the field (not blurred)
        newObject.justReplaced = true; //Before focusing on the clone field, avoid the "onFocus" to reset the field value
        newObject.select();
        newObject.focus();
    }
    return newObject;
}
</script>
